<?php

namespace App\SearchRules;

use ScoutElastic\SearchRule;

class CommentDetailSearchRule extends SearchRule
{
    /**
     * @inheritdoc
     */
    public function buildHighlightPayload()
    {
        return [
            "pre_tags" => ['<font color="red">'],
            "post_tags" => ['</font>'],
            'fields' => [
                "content.data.text" => ['type' => 'plain'],
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function buildQueryPayload()
    {
        $query = $this->builder->query;
        return [
            "must" => [
                "nested" => [
                    "path" => "content",
                    "query" => [
                        "match" => ["content.data.text" => $query]
                    ],
                ],
            ],
        ];
    }
}